home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Presentations / Presentations ’97 / Sessions ’97 / Multiplatform Code⁄Data Sharing / HelloBothWorlds / Libraries / stream.h < prev    next >
Encoding:
Text File  |  1997-06-26  |  838 b   |  44 lines  |  [TEXT/CWIE]

  1.  
  2. // mail <chelly@eden.com> or surf http://www.eden.com/~chelly for feedback
  3. // free source code - do whatever you like with it
  4.  
  5. // sequential access to file data
  6. // automatically swaps multi-byte integral types, so it's easier to use
  7.  
  8. #ifndef stream_H
  9. #define stream_H
  10.  
  11. #include "common.h"
  12.  
  13. #include <stdio.h> // for FILE structure
  14.  
  15. class stream {
  16. public:
  17.     
  18.     stream( const char* path_of_file ); // open file
  19.     ~stream();
  20.     
  21.     // go to offset in file
  22.     void set_mark( long new_mark );
  23.  
  24.     // skip n bytes in file
  25.     void skip( long n_bytes );
  26.  
  27.     // read n bytes from file into storage
  28.     void get_bytes( void* storage, long n );
  29.     
  30.     // read a byte from the file
  31.     uint8    get_uint8(); 
  32.     
  33.     // read a word from file in big endian format (and swap if necessary )    
  34.     uint16    get_mac_uint16();
  35.     uint32    get_mac_uint32();
  36.  
  37. private:
  38.  
  39.     FILE* m_file;
  40. };
  41.  
  42. #endif
  43.  
  44.